﻿using Jayden.Dll.Core;
using Jayden.Dll.Core.Persistence;
using Jayden.Dll.Core.Persistence.Data.SQLite;
using Jayden.Dll.Core.Persistence.Models;
using System.Collections.Generic;
using System.Data.Common;
using Jayden.Dll.Core.Persistence.Data;

namespace Jayden.Dll.Cards.Poker
{
	public class SQLiteTexasHoldemHandActionDataAccess : SQLiteDataAccess<TexasHoldemHandAction>, TexasHoldemHandActionDataAccess
	{
		public SQLiteTexasHoldemHandActionDataAccess(Configuration config, UnitOfWork uow, Entity entity) : base(config, uow, entity) { }



		public List<TexasHoldemHandAction> ReadByHandId(long handId)
		{
			string selectCommandText = Helper.GenerateSelect(Entity, Entity["HandId"]);
			using (DbCommandProxy selectCommand = CreateCommand(selectCommandText))
			{
				CreateParameter(selectCommand, "HandId", handId);
				using (DbDataReader reader = selectCommand.Command.ExecuteReader())
				{
					return new List<TexasHoldemHandAction>(EnumerateFromReader(reader));
				}
			}
		}

		public List<TexasHoldemHandAction> ReadByHandIdAndStreet(long handId, Enums.PokerStreetType street)
		{
			string selectCommandText = Helper.GenerateSelect(Entity, Entity["HandId"], Entity["Street"]);
			using (DbCommandProxy selectCommand = CreateCommand(selectCommandText))
			{
				CreateParameter(selectCommand, "HandId", handId);
				CreateParameter(selectCommand, "Street", street);
				using (DbDataReader reader = selectCommand.Command.ExecuteReader())
				{
					return new List<TexasHoldemHandAction>(EnumerateFromReader(reader));
				}
			}
		}
	}
}
